package com.starsea.book.ui.newpage.pop

import android.content.Context
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import com.lxj.xpopup.core.CenterPopupView
import com.starsea.book.R
import com.starsea.book.utils.gone
import com.starsea.book.utils.visible

/**
 * @author Lee
 * @createTime 2023-08-04 16 GMT+8
 * @desc :
 */
class WelfareGetCoinPop(
    var mContext: Context,
    var adver: Int,
    var isCount: Boolean = false,
    var coin: String,
    var coinAgain: String,
    var boxId:String,
    var onResult: ((value: String) -> Unit)? = null
) :
    CenterPopupView(mContext) {

    override fun getImplLayoutId(): Int {
        return R.layout.layout_welfare_get_coin_pop
    }

    override fun onCreate() {
        super.onCreate()

        var iv_close: ImageView = findViewById(R.id.iv_close)
        iv_close.setOnClickListener { dismiss() }

        var tv_coin: TextView = findViewById(R.id.tv_coin)
        var tv_title: TextView = findViewById(R.id.tv_title)
        var ll_coin: LinearLayout = findViewById(R.id.ll_coin)

        tv_coin.text = "+${coin}"

        var tv_confim: TextView = findViewById(R.id.tv_confim)
        if (adver == 2) {
//            本轮开宝箱得金币你已经领过啦，倒计时结束后还可以再开宝箱哟~!
            tv_confim.text = "看小视频再领${coinAgain}金币"
            tv_confim.setOnClickListener {
                onResult!!.invoke("")
                dismiss()
            }
        } else {
            tv_confim.text = "好的"
            tv_confim.setOnClickListener {
                dismiss()
            }
        }

        if (isCount) {
            ll_coin.gone()
            tv_title.text = "本轮开宝箱得金币你已经领过啦，倒计时结束后还可以再开宝箱哟~!"

        } else {
            ll_coin.visible()
        }


    }

}